package com.heima.admin.job;

import com.heima.admin.service.WemediaNewsAutoScanService;
import com.heima.feigns.wemedia.WemediaFeign;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Slf4j
public class WeMediaNewsAutoScanJob {
    @Autowired
    WemediaFeign wemediaFeign;
    @Autowired
    WemediaNewsAutoScanService wemediaNewsAutoScanService;
    @XxlJob("wemediaAutoScanJob")
    public ReturnT<String> autoScanJob(String param){
        //远程调用方法查询需要发布的文章
        log.info("任务调用开始=========");
        List<Integer> list = wemediaFeign.findRelease();
        if(list!=null){
            for (Integer integer : list) {
                wemediaNewsAutoScanService.autoScanByMediaNewsId(integer);
            }
            log.info("任务调用结束=========");
        }
        return ReturnT.SUCCESS;
    }
}
